home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / os2 / e33el2.zip / emacs / 19.33 / lisp / ediff-mult.el < prev    next >
Text File  |  1996-07-02  |  60KB  |  1,626 lines

  1. ;;; ediff-mult.el --- support for multi-file/multi-buffer processing in Ediff
  2.  
  3. ;; Copyright (C) 1995, 1996 Free Software Foundation, Inc.
  4.  
  5. ;; Author: Michael Kifer <kifer@cs.sunysb.edu>
  6.  
  7. ;; This file is part of GNU Emacs.
  8.  
  9. ;; GNU Emacs is free software; you can redistribute it and/or modify
  10. ;; it under the terms of the GNU General Public License as published by
  11. ;; the Free Software Foundation; either version 2, or (at your option)
  12. ;; any later version.
  13.  
  14. ;; GNU Emacs is distributed in the hope that it will be useful,
  15. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. ;; GNU General Public License for more details.
  18.  
  19. ;; You should have received a copy of the GNU General Public License
  20. ;; along with GNU Emacs; see the file COPYING.  If not, write to the
  21. ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  22. ;; Boston, MA 02111-1307, USA.
  23.  
  24. ;;; Commentary:
  25.  
  26. ;; Users are encouraged to add functionality to this file.
  27. ;; The present file contains all the infrastructure needed for that.
  28. ;;
  29. ;; Generally, to to implement a new multisession capability within Ediff,
  30. ;; you need to tell it 
  31. ;;
  32. ;;    1. How to display the session group buffer.
  33. ;;       This function must indicate which Ediff sessions are active (+) and
  34. ;;       which are finished (-).
  35. ;;       See ediff-redraw-directory-group-buffer for an example.
  36. ;;       In all likelihood, ediff-redraw-directory-group-buffer can be used
  37. ;;       directly or after a small modification.
  38. ;;    2. What action to take when the user clicks button 2 or types v,e, or
  39. ;;       RET.  See ediff-filegroup-action.
  40. ;;    3. Provide a list of pairs or triples of file names (or buffers,
  41. ;;       depending on the particular Ediff operation you want to invoke)
  42. ;;       in the following format:
  43. ;;          (descriptor (obj1 obj2 obj3) (...) ...)
  44. ;;       Actually, the format of this list is pretty much up to the
  45. ;;       developer. The only thing is that it must be a list of lists,
  46. ;;       and the first list must describe the meta session, and subsequent
  47. ;;       elements must describe individual sessions.
  48. ;;       This descriptor must be a list of two, three, or four elements (nil
  49. ;;       or string). The function ediff-redraw-registry-buffer displays the
  50. ;;       second through last of these in the registry buffer. 
  51. ;;       Also, keep in mind that the function ediff-prepare-meta-buffer
  52. ;;       (which see) prepends the session group buffer to the descriptor and
  53. ;;       nil in front of each subsequent list (i.e., the above list 
  54. ;;       will become
  55. ;;              ((meta-buf descriptor) (nil obj1 obj2 obj3) (nil ...) ...)
  56. ;;       Ediff expects that your function (in 2 above) will arrange to
  57. ;;       replace this prepended nil (via setcar) with the actual ediff
  58. ;;       control buffer associated with an appropriate Ediff session.
  59. ;;       This is arranged through internal startup hooks that can be passed
  60. ;;       to any of Ediff major entries (such as ediff-files, epatch, etc.).
  61. ;;       See how this is done in ediff-filegroup-action.
  62. ;;
  63. ;;       Session descriptions are of the form (obj1 obj2 obj3), which
  64. ;;       describe objects relevant to the session. Usually they are names of
  65. ;;       files, but sometimes they may be other things. For instance, obj3 is
  66. ;;       nil for jobs that involve only two files. For patch jobs, obj2 and
  67. ;;       obj3 are markers that specify the patch corresponding to the file
  68. ;;       (whose name is obj1).
  69. ;;    4. Write a function that makes a call to ediff-prepare-meta-buffer
  70. ;;       passing all this info. 
  71. ;;       You may be able to use ediff-directories-internal as a template.
  72. ;;    5. If you intend to add several related pieces of functionality,
  73. ;;       you may want to keep the function in 4 as an internal version
  74. ;;       and then write several top-level interactive functions that call it
  75. ;;       with different parameters.
  76. ;;       See how ediff-directories, ediff-merge-directories, and
  77. ;;       ediff-merge-directories-with-ancestor all use
  78. ;;       ediff-directories-internal. 
  79. ;;
  80. ;; A useful addition here could be session groups selected by patterns
  81. ;; (which are different in each directory). For instance, one may want to
  82. ;; compare files of the form abc{something}.c to files old{something}.d
  83. ;; which may be in the same or different directories. Or, one may want to
  84. ;; compare all files of the form {something} to files of the form {something}~.
  85. ;;
  86. ;; Implementing this requires writing an collating function, which should pair
  87. ;; up appropriate files. It will also require a generalization of the functions
  88. ;; that do the layout of the meta- and differences buffers and of
  89. ;; ediff-filegroup-action.
  90.  
  91. ;;; Code:
  92.  
  93. (require 'ediff-init)
  94.  
  95. ;; meta-buffer
  96. (ediff-defvar-local ediff-meta-buffer nil "")
  97. (ediff-defvar-local ediff-parent-meta-buffer nil "")
  98. ;; the registry buffer
  99. (defvar ediff-registry-buffer nil)
  100.  
  101. (defconst ediff-meta-buffer-message "This is an Ediff Session Group Panel: %s
  102.  
  103. Useful commands:
  104.      button2, `v', RET over a session line:   start that Ediff session
  105.      `M':\tin any session invoked from here, brings back this group panel
  106.      `R':\tdisplay the registry of active Ediff sessions
  107.      `h':\tmark session for hiding (toggle)
  108.      `x':\thide marked sessions; with prefix arg--unhide hidden sessions
  109.      `m':\tmark session for a non-hiding operation (toggle)
  110.      SPC:\tnext session
  111.      DEL:\tprevious session
  112.      `E':\tbrowse Ediff on-line manual
  113.      `q':\tquit this session group
  114. ")
  115.  
  116. (ediff-defvar-local ediff-meta-buffer-map nil
  117.   "The keymap for the meta buffer.")
  118. (defvar ediff-dir-diffs-buffer-map (make-sparse-keymap)
  119.   "The keymap to be installed in the buffer showing differences between
  120. directories.")
  121.  
  122. ;; Variable specifying the action to take when the use invokes ediff in the
  123. ;; meta buffer. This is usually ediff-registry-action or ediff-filegroup-action
  124. (ediff-defvar-local ediff-meta-action-function nil "")
  125. ;; Tells ediff-update-meta-buffer how to redraw it
  126. (ediff-defvar-local ediff-meta-redraw-function nil "")
  127. ;; Tells ediff-filegroup-action and similar procedures how to invoke Ediff for
  128. ;; the sessions in a given session group
  129. (ediff-defvar-local ediff-session-action-function nil "")
  130.  
  131. (ediff-defvar-local ediff-metajob-name nil "")
  132.  
  133. ;; buffer used to collect custom diffs from individual sessions in the group
  134. (ediff-defvar-local ediff-meta-diff-buffer nil "")
  135.  
  136. ;; history var to use for filtering groups
  137. (defvar ediff-filtering-regexp-history nil "")
  138.  
  139. ;; This has the form ((ctl-buf file1 file2) (stl-buf file1 file2) ...)
  140. ;; If ctl-buf is nil, the file-pair wasn't processed yet. If it is
  141. ;; killed-buffer object, the file pair has been processed. If it is a live
  142. ;; buffer, this means ediff is still working on the pair
  143. (ediff-defvar-local ediff-meta-list nil "")
  144.  
  145.  
  146. ;; the difference list between directories in a directory session group
  147. (ediff-defvar-local ediff-dir-difference-list nil "")
  148. (ediff-defvar-local ediff-dir-diffs-buffer nil "")
  149.  
  150. ;; The registry of Ediff sessions. A list of control buffers.
  151. (defvar ediff-session-registry nil)
  152.  
  153. (defvar ediff-registry-setup-hook nil
  154.   "*Hooks run just after the registry control panel is set up.")
  155. (defvar ediff-session-group-setup-hook nil
  156.   "*Hooks run just after a meta-buffer controlling a session group, such as
  157. ediff-directories, is run.")
  158. (defvar ediff-show-registry-hook nil
  159.   "*Hooks run just after the registry buffer is shown.")
  160. (defvar ediff-show-session-group-hook nil
  161.   "*Hooks run just after a session group buffer is shown.")
  162.  
  163. ;; buffer holding the multi-file patch. local to the meta buffer
  164. (ediff-defvar-local ediff-meta-patchbufer nil "")
  165.  
  166. ;;; API for ediff-meta-list
  167.  
  168. ;; group buffer/regexp
  169. (defun ediff-get-group-buffer (meta-list)
  170.   (nth 0 (car meta-list)))
  171. (defun ediff-get-group-regexp (meta-list)
  172.   (nth 1 (car meta-list)))
  173. ;; group objects
  174. (defun ediff-get-group-objA (meta-list)
  175.   (nth 2 (car meta-list)))
  176. (defun ediff-get-group-objB (meta-list)
  177.   (nth 3 (car meta-list)))
  178. (defun ediff-get-group-objC (meta-list)
  179.   (nth 4 (car meta-list)))
  180. ;; session buffer
  181. (defun ediff-get-session-buff